"use strict";

function initialize() {
    var moscowLatLng = new google.maps.LatLng(55.751667, 37.617778);
    var mapOptions = {
        zoom: 10,
        center: moscowLatLng
    };

    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

    hospitals.forEach(function (p) {
        var marker = new google.maps.Marker({
            map: map,
            position: new google.maps.LatLng(p.lat, p.lng),
            title: p.name
        });

        var infowindow = new google.maps.InfoWindow({
            content: '<div>' +
                '<p>' + p.name + '</p>' +
                '<p>' + p.address + '</p>' +
                '</div>'
        });

        google.maps.event.addListener(marker, 'click', function () {
            infowindow.open(map, marker);
        });
    });
}

google.maps.event.addDomListener(window, 'load', initialize);